home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sources / libxpm / libxpm34.gz / libxpm34 / xpm-3.4 / lib / XpmCrIFrData.c < prev    next >
C/C++ Source or Header  |  1994-03-14  |  2KB  |  76 lines

  1. /* Copyright 1989-94 GROUPE BULL -- See license conditions in file COPYRIGHT */
  2. /*****************************************************************************\
  3. * XpmCrIFrData.c:                                                             *
  4. *                                                                             *
  5. *  XPM library                                                                *
  6. *  Parse an Xpm array and create the image and possibly its mask              *
  7. *                                                                             *
  8. *  Developed by Arnaud Le Hors                                                *
  9. \*****************************************************************************/
  10.  
  11. #include "xpmP.h"
  12.  
  13. int
  14. XpmCreateImageFromData(display, data, image_return,
  15.                shapeimage_return, attributes)
  16.     Display *display;
  17.     char **data;
  18.     XImage **image_return;
  19.     XImage **shapeimage_return;
  20.     XpmAttributes *attributes;
  21. {
  22.     XpmImage image;
  23.     XpmInfo info;
  24.     int ErrorStatus;
  25.  
  26.     /* create an XpmImage from the file */
  27.     if (attributes) {
  28.     xpmInitAttributes(attributes);
  29.     xpmSetInfoMask(&info, attributes);
  30.     ErrorStatus = XpmCreateXpmImageFromData(data, &image, &info);
  31.     } else
  32.     ErrorStatus = XpmCreateXpmImageFromData(data, &image, NULL);
  33.  
  34.     if (ErrorStatus != XpmSuccess)
  35.         return (ErrorStatus);
  36.  
  37.     /* create the related ximages */
  38.     ErrorStatus = XpmCreateImageFromXpmImage(display, &image,
  39.                          image_return, shapeimage_return,
  40.                          attributes);
  41.     if (attributes) {
  42.     if (ErrorStatus >= 0)    /* no fatal error */
  43.         xpmSetAttributes(attributes, &image, &info);
  44.     XpmFreeXpmInfo(&info);
  45.     }
  46.  
  47.     XpmFreeXpmImage(&image);
  48.  
  49.     return (ErrorStatus);
  50. }
  51.  
  52. int
  53. XpmCreateXpmImageFromData(data, image, info)
  54.     char **data;
  55.     XpmImage *image;
  56.     XpmInfo *info;
  57. {
  58.     xpmData mdata;
  59.     int ErrorStatus;
  60.  
  61.     /* init returned values */
  62.     xpmInitXpmImage(image);
  63.     xpmInitXpmInfo(info);
  64.  
  65.     /* open data */
  66.     xpmOpenArray(data, &mdata);
  67.  
  68.     /* create the XpmImage from the XpmData */
  69.     ErrorStatus = xpmParseData(&mdata, image, info);
  70.  
  71.     xpmDataClose(&mdata);
  72.  
  73.     return (ErrorStatus);
  74. }
  75.  
  76.